import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import Layout from '@/layout'

export const constantRoutes = [{
  path: '/login',
  component: () => import('@/views/login/index'),
  hidden: true
},

{
  path: '/404',
  component: () => import('@/views/404'),
  hidden: true
},

{
  path: '/',
  component: Layout,
  redirect: '/dashboard',
  children: [{
    path: 'dashboard',
    name: '首页',
    component: () => import('@/views/dashboard/index'),
    meta: {
      title: '首页',
      icon: 'dashboard'
    }
  }]
},


{
  path: '/classiCase',
  component: Layout,
  redirect: '/classiCase/case',
  name: '经典案例',
  meta: {
    title: '经典案例',
    icon: 'el-icon-star-off'
  },
  children: [
    {
      path: 'case',
      component: () => import('@/views/classiCase/case'),
      name: '案例列表',
      meta: { title: '案例列表' }
    },
    //  {
    //   path: 'classification',
    //   component: () => import('@/views/classiCase/classification'),
    //   name: '案例分类',
    //   meta: { title: '案例分类' }
    // }, 
    {
      path: 'saveCase',
      component: () => import('@/views/classiCase/saveCase'),
      name: '新增案例',
      meta: { title: '新增案例' }
    }
  ]
},

{
  path: '/successCase',
  component: Layout,
  redirect: '/successCase/caseList',
  name: '成功案例',
  meta: {
    title: '成功案例',
    icon: 'el-icon-star-off'
  },
  children: [
    {
      path: 'caseList',
      name: '案例列表',
      component: () => import('@/views/successCase/caseList'),
      meta: {
        title: '案例列表',

      }
    },
    {
      path: 'caseification',
      component: () => import('@/views/successCase/caseification'),
      name: '案例分类',
      meta: { title: '案例分类' }
    },
    {
      path: 'addCase',
      name: '新增案例',
      component: () => import('@/views/successCase/addCase'),
      meta: {
        title: '新增案例',
      }
    }]
},
{
  path: '/new',
  component: Layout,
  redirect: '/new/newsList',
  name: '新闻资讯',
  meta: {
    title: '新闻资讯',
    icon: 'el-icon-document-copy'
  },
  children: [
    {
      path: 'newsList',
      name: '资讯列表',
      component: () => import('@/views/news/newsList'),
      meta: {
        title: '资讯列表'
      }
    },
    {
      path: 'addnews',
      name: '新增资讯',
      component: () => import('@/views/news/addnews'),
      meta: {
        title: '新增资讯'
      }
    }
  ]
},

// bannerlist---话题动态
{
  path: '/topic',
  component: Layout,
  redirect: '/topicDynamic/bannerList',
  name: '话题动态',
  meta: {
    title: '话题动态',
    icon: 'el-icon-document-copy'
  },
  children: [
    {
      path: 'bannerList',
      name: '话题列表',
      component: () => import('@/views/topicDynamic/bannerList'),
      meta: {
        title: '话题列表'
      }
    },
    {
      path: 'addTopic',
      name: '新增话题',
      component: () => import('@/views/topicDynamic/addTopic'),
      meta: {
        title: '新增话题'
      }
    }
  ]
},
{
  path: '/partners',
  component: Layout,
  redirect: '/partners',
  children: [{
    path: 'partners',
    name: '合作伙伴',
    component: () => import('@/views/partners/partners'),
    meta: {
      title: '合作伙伴',
      icon: 'el-icon-user'
    }
  }]
},
{
  path: '/leaveMsg',
  component: Layout,
  redirect: '/leaveMsg/msgList',
  name: '留言管理',
  meta: {
    title: '留言管理',
    icon: 'el-icon-message'
  },
  children: [
    {
      path: 'msgList',
      name: '留言列表',
      component: () => import('@/views/leaveMsg/msgList'),
      meta: {
        title: '留言列表',
      },
    }]
},
{
  path: '/info',
  component: Layout,
  redirect: '/info/userInfo',
  name: '基础信息',
  meta: {
    title: '基础信息',
    icon: 'el-icon-files'
  },
  children: [
    {
      path: 'userInfo',
      name: '个人信息',
      component: () => import('@/views/basic/userInfo'),
      meta: {
        title: '个人信息',
      }
    },
    {
      path: 'editpass',
      name: '修改密码',
      component: () => import('@/views/basic/editpass'),
      meta: {
        title: '修改密码',
      }
    },
  ]
},


{
  path: '*',
  redirect: '/404',
  hidden: true
}
]

const createRouter = () => new Router({
  // mode: 'history',
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
